// ============================== 导入依赖 ============================== //

import CORE from '@/CORE'
import Client from '@api/equipment/api/AssetOperateApi'

import SubmitClass from '@api/equipment/model/AssetOperateApplyReq'
import Online from '@api/equipment/model/Online'
import ErrorBody from '@api/equipment/model/ErrorBody'
import Repair from '@api/equipment/model/Repair'
import Scarp from '@api/equipment/model/Scarp'

const CLIENT = CORE.grpcCLIENT(Client)

// ============================== 导出远程接口 ============================== //

export default {
  // —————————————————————————————— 提交 —————————————————————————————— //

  async submit(param, TIP = '操作') {
    let BASE
    if (param.operateType === 1) BASE = [Online, 'online']
    if (param.operateType === 2) BASE = [ErrorBody, 'errorBody']
    if (param.operateType === 3) BASE = [Repair, 'repair']
    if (param.operateType === 4) BASE = [Scarp, 'scarp']
    const DTO = CORE.grpcDTO(SubmitClass, param, BASE)
    await CORE.grpc(TIP, CLIENT, 'assetOperateApply', DTO)
    return CORE.grpcOK(TIP)
  },
}
